package singsong;

public class VolumeAnalyzer {
	private float sampleSum = 0;
	
	private int numSamples = 0;
	
	public void addSample(float sample) {
		sampleSum += Math.abs(sample);
		++numSamples;
	}
	
	public float getVolume() {
		float volume = sampleSum / numSamples;
		sampleSum = 0;
		numSamples = 0;
		return volume;
	}
}
